import apiUrl from '../base'
import axios from '@/libs/axios'

const userManagement = {
  getTree() {
    return axios.request({
      url: `${apiUrl.base}v1/OrgTree/tree/searchEnterpriseAndTeamProjectTree`,
      method: 'post'
    })
  },
  getList(data) {
    return axios.request({
      url: `${apiUrl.base}v1/User/list`,
      data,
      method: 'post'
    })
  },
  getStatusList() {
    return axios.request({
      url: `${apiUrl.base}v1/Dict/getListByTypeCode/USER_STATE`,
      method: 'get'
    })
  },
  getTypeList() {
    return axios.request({
      url: `${apiUrl.base}v1/Dict/getListByTypeCode/USER_TYPE`,
      method: 'get'
    })
  },
  changeStatus({ userId, isOpen }) {
    //禁用启用
    let data = {
      userId,
      isOpen
    }
    return axios.request({
      url: `${apiUrl.base}v1/User/edit/enableAndDisable`,
      data,
      method: 'post'
    })
  },
  resetPassWord(id, password) {
    let data = {
      oldPassword: '',
      newPassword: password,
      userId: id
    }
    return axios.request({
      url: `${apiUrl.base}v1/Login/reset`,
      data,
      method: 'post'
    })
  }
}
export default userManagement
